home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 September (Japanese) / CICA Shareware for Windows CD-ROM (Walnut Creek) (September 1995) (Japanese) (Disc 2).iso / disc2 / nt / source.exe / POSIX / INCLUDE / DF / VARARGS.H < prev   
Encoding:
C/C++ Source or Header  |  1993-03-06  |  1.9 KB  |  77 lines

  1. /***
  2. *varargs.h - XENIX style macros for variable argument functions
  3. *
  4. *    Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *    This file defines XENIX style macros for accessing arguments of a
  8. *    function which takes a variable number of arguments.
  9. *    [System V]
  10. *
  11. ****/
  12.  
  13. #ifndef _INC_VARARGS
  14.  
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18.  
  19. #ifdef __STDC__
  20. #error varargs.h incompatible with ANSI (use stdarg.h)
  21. #endif
  22.  
  23. #ifndef _VA_LIST_DEFINED
  24. typedef char *va_list;
  25. #define _VA_LIST_DEFINED
  26. #endif
  27.  
  28.  
  29.  
  30. #ifdef _X86_
  31. /*
  32.  * define a macro to compute the size of a type, variable or expression,
  33.  * rounded up to the nearest multiple of sizeof(int). This number is its
  34.  * size as function argument (Intel architecture). Note that the macro
  35.  * depends on sizeof(int) being a power of 2!
  36.  */
  37.  
  38. #define _INTSIZEOF(n)     ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
  39.  
  40. #define va_dcl va_list va_alist;
  41. #define va_start(ap) ap = (va_list)&va_alist
  42. #define va_arg(ap,t)    ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
  43. #define va_end(ap) ap = (va_list)0
  44. #endif
  45.  
  46. #ifdef M_MRX000
  47.  
  48. #define va_dcl int va_alist;
  49. #define va_start(ap) ap = (va_list)&va_alist
  50. #define va_arg(ap,t) *((t*)(_va_arg(&(ap),sizeof(t),(t*)0,(t*)0)))
  51. #define va_end(ap)
  52.  
  53. #else
  54. #ifdef _MIPS_
  55. #define va_dcl int va_alist;
  56. #define va_start(list) list = (char *) &va_alist
  57. #define va_end(list)
  58. #define va_arg(list, mode) ((mode *)(list =\
  59.  (char *) ((((int)list + (__builtin_alignof(mode)<=4?3:7)) &\
  60.  (__builtin_alignof(mode)<=4?-4:-8))+sizeof(mode))))[-1]
  61. /*  +++++++++++++++++++++++++++++++++++++++++++
  62.     Because of parameter passing conventions in C:
  63.     use mode=int for char, and short types
  64.     use mode=double for float types
  65.     use a pointer for array types
  66.     +++++++++++++++++++++++++++++++++++++++++++ */
  67. #endif
  68. #endif
  69.  
  70.  
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74.  
  75. #define _INC_VARARGS
  76. #endif    /* _INC_VARARGS */
  77.